home *** CD-ROM | disk | FTP | other *** search
/ Mastering Computers 3 / Mastering Computers Vol 3.iso / Win NT / NT Shareware / CLOCK95.ZIP / INTERNET.DLL / TEXT / WILEXCHANGE < prev    next >
Encoding:
Text File  |  1996-09-26  |  3.8 KB  |  155 lines

  1. AddExtender ("WXSock32i.dll")
  2. IntControl (35, 500, 0, 0, 0)
  3. bOK = @TRUE
  4. sDial      = "<dialupname>"
  5. nMaxRedial = <numredials>
  6. nRedialDelay = 10
  7. sPgmPath   = "<pgmpath>"
  8. sPgmDir    = "<pgmdir>"
  9. bAllSvcs   = <allservices>
  10. sServices  = "<services>"
  11. sErrDesc   = ""
  12. nWait      = 5 ; How many minutes to wait for Exchange to finish its work
  13. sWinTitle  = "~ - Microsoft Exchange"
  14.  
  15. ;Dial our host (unless user is on a direct connect)...
  16. hConn = 0
  17. nNumRedials = 0
  18. if (sDial <> "")
  19.     :DialIt
  20.     hConn = DUNConnect (sDial)
  21.     nErr = SGetLastErr ()
  22.     if (!hConn)
  23.         switch nErr
  24.         case @SErrNotFound
  25.             sErrDesc = "Couldn't connect to %sDial%: no such dial-up"
  26.             break
  27.         case @SErrBusy
  28.             if (nNumRedials <= nMaxRedial)
  29.                 nNumRedials = nNumRedials + 1
  30.                 Delay (nRedialDelay)
  31.                 goto DialIt
  32.             else
  33.                 sErrDesc = "Couldn't connect to %sDial%: Line busy"
  34.             endif
  35.             break
  36.         case @SErrNoAnswer
  37.             if (nNumRedials <= nMaxRedial)
  38.                 nNumRedials = nNumRedials + 1
  39.                 Delay (nRedialDelay)
  40.                 goto DialIt
  41.             else
  42.                 sErrDesc = "Couldn't connect to %sDial%: No answer"
  43.             endif
  44.             break
  45.         case @SErrVoice
  46.             sErrDesc = "Couldn't connect to %sDial%: A human answered"
  47.             break
  48.         case nErr ; <--default
  49.             sErrDesc = "Couldn't connect to %sDial% - error %nErr%"
  50.         endswitch
  51.         bOK = @FALSE
  52.         goto LogIt
  53.     else
  54.         if (nErr == @SAlready)
  55.             ; We're already connected. Don't hang up when this event is thru...
  56.             hConn = 0 
  57.         endif
  58.     endif
  59. endif
  60.  
  61.  
  62. ; Run Exchange & make it do things...
  63. if (!WinExist(sWinTitle))
  64.     DirChange (sPgmDir)
  65.     Run (sPgmPath, "")
  66.     while (!WinExist(sWinTitle))
  67.         Delay (1)
  68.     endwhile
  69.     Delay (6)
  70. endif
  71.  
  72. WinActivate (sWinTitle)
  73. sWinTitle = WinGetActive () ; Get actual window name
  74.  
  75. ; Main processing...
  76. if (bAllSvcs)
  77.     SendKeysTo (sWinTitle, "!td~")
  78.     Delay (10)
  79. else
  80.     SendkeysTo (sWinTitle, "!td") ; Force 3rd level menu to be created...
  81.     Delay (1)
  82.     SendkeysTo (sWinTitle, "{esc 3}") ; Back out of menu selection
  83.     Delay (1)
  84.  
  85.     for nSvc = 1 to ItemCount(sServices,@TAB)
  86.         sService = ItemExtract (nSvc, sServices, @TAB)
  87.         gosub WinSelectMenuItem
  88.         Delay (10)
  89.  
  90.         ; Wait for nWait minutes, or till user kills off Exchange manually...
  91.         for n=1 to nWait * 6
  92.             if (WinExist (sWinTitle))
  93.                 Delay (10)
  94.                 if (!WinExist(sWinTitle)) then goto Cancel
  95.                 MouseMove (500+n, 500, "", "")
  96.             endif
  97.         next n
  98.     next nSvc
  99. endif
  100.  
  101.  
  102. ; If user hit Ctrl+Break, WIL will bring us here...
  103. :Cancel
  104.  
  105. ; Hang up...
  106. :HangUp
  107. if (hConn)
  108.     nRet = DUNDisconnect (hConn)
  109. endif
  110.  
  111.  
  112. ; Log what we did...
  113. :LogIt
  114. if bOK == @TRUE
  115.     sLog = "Ran Exchange"
  116. else
  117.     sLog = strcat ("Error attempting to automate Exchange:", @CRLF, sErrDesc)
  118. endif
  119.  
  120. CMLogMessage (sLog)
  121. Display (8, "ClockMan95", sLog)
  122. exit
  123.  
  124.  
  125. ; Select the menu item corresponding to service "sService"...
  126. :WinSelectMenuItem
  127. WSMsSysDir = DirWindows (1)
  128. WSMhUser32 = DllLoad ("%WSMsSysDir%user32.dll")
  129. ;Debug(@ON)
  130. WSMhwnd = IntControl(21, sWinTitle, 0, 0, 0)
  131. WSMhMenu = DllCall(WSMhUser32, long:"GetMenu", long:WSMhwnd)
  132. WSMhMenu = DllCall(WSMhUser32, long:"GetSubMenu", long:WSMhMenu, long:3)
  133. WSMhMenu = DllCall(WSMhUser32, long:"GetSubMenu", long:WSMhMenu, long:0)
  134. if (!WSMhMenu)
  135.     CMLogMessage ("No Services menu found!")
  136. else
  137.     WSMhItem = BinaryAlloc(80)
  138.     BinaryEODSet(WSMhItem, 80)
  139.     WSMnSvcs = DllCall(WSMhUser32, long:"GetMenuItemCount", long:WSMhMenu)
  140.     for WSMn = 2 to WSMnSvcs-1 ; skipping over "All services" & horiz separator
  141.         DllCall(WSMhUser32, long:"GetMenuStringA", long:WSMhMenu, long:WSMn, lpbinary:WSMhItem, long:80, long:1024)
  142.         WSMsItem = BinaryPeekStr(WSMhItem, 0, 80)
  143.         if strindex (WSMsItem, sService, 0, @FWDSCAN) == 1
  144.             ; We found the menu item we're looking for...
  145.             WSMnItem = WSMn - 1
  146.             SendKeysTo (sWinTitle, "^%WSMnItem%") ; Ctrl+1, etc.
  147.         endif
  148.     next WSMn
  149.     BinaryFree (WSMhItem)
  150. endif
  151. DllFree (WSMhUser32)
  152.  
  153. return
  154. ~
  155.